﻿import QtQuick 2.15
import QtQuick.Controls 2.15

Item {
    id: itemChangePort
    anchors.fill: parent
    visible: false

    MouseArea{
        anchors.fill: parent

        onPressed: {
            itemChangePort.visible = false
        }
    }

    Rectangle{
        id: rectChangePort
        width: parent.width*0.6
        height: width/2
        color: "#404142"
        anchors.verticalCenter: parent.verticalCenter
        anchors.horizontalCenter: parent.horizontalCenter

        MouseArea{
            anchors.fill: parent
        }

        Button {
            id: leftChangeUserInfo
            width: parent.height*0.4
            height: width/2
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            anchors.leftMargin: width
            anchors.bottomMargin: height
            text: "确定"

            onClicked: {
                var port = inputChangePort.text
                dbManager.updatePort("UserInfo", port)
                socketManager.initNetwork(port)
                //刷新页面
                pageStackView.clear(StackView.Immediate)
                pageStackView.push("FirstPage.qml", StackView.Immediate)

            }
        }
        Button {
            id: rightChangeUserInfo
            width: parent.height*0.4
            height: width/2
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            anchors.rightMargin: width
            anchors.bottomMargin: height
            text: "取消"

            onClicked: {
                itemChangePort.visible = false
            }
        }

        Text {
            id: textChangePort
            color: "#ffffff"
            text: qsTr("端口：")
            anchors.left: parent.left
            anchors.top: parent.top
            horizontalAlignment: Text.AlignHCenter
            verticalAlignment: Text.AlignVCenter
            anchors.leftMargin: parent.width*0.2
            font.bold: true
            font.pointSize: 10
            anchors.topMargin: parent.height*0.2
        }

        TextInput{
            id: inputChangePort
            anchors.left: textChangePort.right
            anchors.top: parent.top
            anchors.topMargin: parent.height*0.2
            maximumLength: 6
            width: parent.width*0.4
            height: textChangePort.height
            color: "#000000"
            anchors.leftMargin: height/2
            selectByMouse: true
            leftPadding: 2
            topPadding: 1
            z: 2
        }
        Rectangle{
            anchors.fill: inputChangePort
            color: "#ffffff"
            z: 1
        }


    }

}

/*##^##
Designer {
    D{i:0;autoSize:true;height:480;width:640}
}
##^##*/
